<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <title>工控发货信息列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link rel="icon" th:href="@{/static/console/common/images/favicon.ico}">
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/element/index.css}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/static/console/css/production/component/invoice-detail.css?version=202501071001}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/static/console/css/production/component/indent-select.css?version=202501071001}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/static/console/css/production/component/invoice-select.css?version=202501071001}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/static/console/css/production/control-invoice.css?version=202501071001}"/>

</head>

<body>
<div id="container">
    <el-container>
        <el-header>
            <el-date-picker v-model="tableSearch.startTime"
                            type="datetime"
                            :value-format="tableSearch.dateFormat"
                            placeholder="起始日期">
            </el-date-picker>
            <el-date-picker v-model="tableSearch.endTime"
                            type="datetime"
                            :value-format="tableSearch.dateFormat"
                            placeholder="截止日期">
            </el-date-picker>
            <el-input v-model="tableSearch.site" placeholder="施工部位" clearable></el-input>
            <el-select v-model="tableSearch.conAuto" placeholder="是否手动生产" clearable>
                <el-option v-for="item in conAutoOptions"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value">
                </el-option>
            </el-select>
            <el-select v-model="tableSearch.linkErp" placeholder="是否已关联ERP" clearable>
                <el-option v-for="item in linkErpOptions"
                           :key="item.value"
                           :label="item.label"
                           :value="item.value">
                </el-option>
            </el-select>
            <el-button type="success" icon="el-icon-search" @click="searchDatas" size="mini">查询</el-button>
            <el-button type="primary" icon="el-icon-upload2" @click="exportData" size="mini">导出</el-button>
            <el-button icon="el-icon-refresh" @click="syncControl" size="mini">同步</el-button>
            <el-button icon="el-icon-refresh" @click="syncControlAll" size="mini">全量同步</el-button>
        </el-header>
        <el-main>
            <template>
                <el-table :data="tableDatas" border v-loading="tableLoading" max-height="750">
                    <el-table-column label="序号"
                                     show-overflow-tooltip
                                     type="index"
                                     width="50"></el-table-column>
                    <el-table-column prop="controlInvoiceNo" show-overflow-tooltip
                                     label="发货单编号"
                                     width="210"></el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="conName"
                                     label="工程名称"
                                     width="240"></el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="site"
                                     label="施工部位"
                                     width="240"></el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="strengthName"
                                     label="砼强度"
                                     width="180">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="tech"
                                     label="特性要求"
                                     width="180">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="concreteStere"
                                     label="砼方量(方)"
                                     width="120">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="mortarStere"
                                     label="砂浆方量(方)"
                                     width="120">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="totalCar"
                                     label="车次"
                                     width="120">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="proTime"
                                     label="生产时间"
                                     width="180">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="castModel"
                                     label="浇筑方式"
                                     width="150">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     label="搅拌车"
                                     width="150">
                        <template slot-scope="scope">
                            {{scope.row.carCode}}-{{scope.row.carNo}}
                        </template>
                    </el-table-column>
                    <el-table-column label="生产线"
                                     prop="lineName"
                                     width="80"></el-table-column>
                    <el-table-column show-overflow-tooltip
                                     label="是否ERP派单"
                                     width="150">
                        <template slot-scope="scope">
                            <el-tag v-if="scope.row.conAuto == 1" type="warning">工控生产</el-tag>
                            <el-tag v-else>ERP派单</el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     label="是否关联ERP"
                                     width="150">
                        <template slot-scope="scope">
                            <el-tag v-if="scope.row.linkErp == 1">已关联</el-tag>
                            <el-tag v-else type="warning">未关联</el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column fixed="right"
                                     label="操作"
                                     width="300">
                        <template scope="scope">
                            <el-button icon="el-icon-coin" size="mini" type="success"
                                       @click="loadExpendDatas(scope.row)">消耗
                            </el-button>
                            <template v-if="scope.row.conAuto == 1 && scope.row.linkErp != 1">
                                <el-button icon="el-icon-circle-plus" size="mini" type="primary"
                                           @click="showAddDialog(scope.row)">新建
                                </el-button>
                                <el-button icon="el-icon-connection" size="mini" type="primary"
                                           @click="showLinkDialog(scope.row)">关联
                                </el-button>
                            </template>
                            <template v-if="scope.row.conAuto == 1 && scope.row.linkErp == 1">
                                <el-button icon="el-icon-view" size="mini" type="info"
                                           @click="showInvoiceDialog(scope.row.id)">发货单
                                </el-button>
                            </template>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination background
                               @size-change="handleSizeChange"
                               @current-change="handleCurrentChange"
                               :page-sizes="[50, 100, 200,500]"
                               :page-size="tableSearch.limit"
                               :current-page.sync="tableSearch.pageIndex"
                               layout="total,sizes, prev, pager, next"
                               :total="tableSearch.total">
                </el-pagination>
            </template>
        </el-main>
    </el-container>
    <el-dialog title="创建ERP数据" :visible.sync="addInvDialog.show" width="95%" center v-loading="addInvDialog.loading"
               :close-on-click-modal="0" :show-close="0" custom-class="add-dialog">
        <el-form label-position="right" label-width="140px" :inline="true" :model="addInvForm"
                 :rules="linkRules" ref="addInvForm">
            <indent-select @change="indentChange" v-if="addInvDialog.show"></indent-select>
            <!--  需要录入的信息  -->
            <el-form-item label="生产方量" required prop="render.proStere">
                <el-input v-model="addInvForm.render.proStere" type="number"></el-input>
            </el-form-item>
            <el-form-item label="发货方量" required prop="render.sendStere">
                <el-input v-model="addInvForm.render.sendStere" type="number"></el-input>
            </el-form-item>
            <el-form-item label="生产时间" required prop="render.proTime">
                <el-date-picker v-model="addInvForm.render.proTime"
                                value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="生产时间">
                </el-date-picker>
            </el-form-item>
            <br>
            <el-form-item label="调度员" required prop="render.dispatcherName">
                <el-select v-model="addInvForm.render.dispatcherName" filterable clearable placeholder="调度员"
                           value-key="id">
                    <el-option v-for="item in dispatcherList"
                               :key="item.id"
                               :label="item.name"
                               :value="item.name"
                               @click.native="dispatcherChange(item)">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="拌台操作员" required>
                <el-select v-model="addInvForm.render.mixUserName" filterable clearable placeholder="拌台操作员"
                           value-key="id">
                    <el-option v-for="item in mixUserList"
                               :key="item.id"
                               :label="item.name"
                               :value="item.name"
                               @click.native="mixUserChange(item)">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="车号" required prop="render.carId">
                <el-select v-model="addInvForm.render.carId" filterable clearable placeholder="车号"
                           value-key="id">
                    <el-option v-for="item in carList"
                               :key="item.id"
                               :label="item.code"
                               :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="司机">
                <el-input v-model="addInvForm.render.driver"></el-input>
            </el-form-item>
            <br>
            <el-form-item label="是否累计方量" required prop="render.isAdd">
                <el-radio-group v-model="addInvForm.render.isAdd">
                    <el-radio label="0">累计</el-radio>
                    <el-radio label="1">不累计</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="是否计算运输方量" required>
                <el-radio-group v-model="addInvForm.render.calcTranStere">
                    <el-radio label="0">计算</el-radio>
                    <el-radio label="1">不计算</el-radio>
                </el-radio-group>
            </el-form-item>
            <br>
            <el-form-item label="票据类型">
                <el-select v-model="addInvForm.render.receiptType" filterable clearable placeholder="票据类型"
                           value-key="id">
                    <el-option v-for="item in receiptTypeList"
                               :key="item.code"
                               :label="item.desc"
                               :value="item.code + ''">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="特殊结算类型">
                <el-select v-model="addInvForm.render.specialClearType" filterable clearable placeholder="特殊结算类型"
                           value-key="id">
                    <el-option v-for="item in specialClearTypeList"
                               :key="item.code"
                               :label="item.desc"
                               :value="item.code + ''">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="道路类型">
                <el-select v-model="addInvForm.render.roadType" filterable clearable placeholder="道路类型"
                           value-key="id">
                    <el-option v-for="item in roadTypeList"
                               :key="item.code"
                               :label="item.desc"
                               :value="item.code + ''">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="备注" class="invoice-remark">
                <el-input type="textarea" :rows="2" v-model="addInvForm.render.remark"></el-input>
            </el-form-item>
            <el-form-item label="运输备注" class="invoice-remark">
                <el-input type="textarea" :rows="2" v-model="addInvForm.render.tranRemark"></el-input>
            </el-form-item>
            <el-form-item label="泵送备注" class="invoice-remark">
                <el-input type="textarea" :rows="2" v-model="addInvForm.render.pumpRemark"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="addSubmit('addInvForm')">确定</el-button>
            <el-button @click="cancel()">取 消</el-button>
        </div>
    </el-dialog>
    <!--    关联发货单   -->
    <el-dialog title="关联发货单" :visible.sync="linkInvDialog.show" width="60%" center v-loading="linkInvDialog.loading"
               :close-on-click-modal="0" :show-close="0" custom-class="add-dialog">
        <el-form label-position="right" label-width="140px" :inline="true" :model="linkInvForm" ref="linkInvForm">
            <invoice-select @change="invoiceChange" v-if="linkInvDialog.show" :invoice-type="1"
                            :is-linked="-1"></invoice-select>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="linkSubmit">确定</el-button>
            <el-button @click="cancel()">取 消</el-button>
        </div>
    </el-dialog>
    <!--  发货单详情  -->
    <invoice-detail-dialog v-if="erpInvDialog.show" :invoice-id="erpInvDialog.id"
                           @closed="erpInvDialog.show = false"></invoice-detail-dialog>
    <!-- 工控消耗查询 -->
    <el-dialog title="工控发货单消耗" :visible.sync="expendDialog.show" width="70%" center :close-on-click-modal="0"
               v-loading="expendDialog.loading" custom-class="con-inv-expend-dialog">
        <el-descriptions title="工程信息" :column="7" size="mini" border class="invoice-data-desc"
                         label-class-name="invoice-data-desc-label">
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-office-building"></i>项目名称
                </template>
                {{conInvoice.conName}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-operation"></i>施工部位
                </template>
                {{conInvoice.site}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-operation"></i>强度等级
                </template>
                {{conInvoice.strengthName}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-operation"></i>砂浆方量
                </template>
                {{conInvoice.mortarStere}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-operation"></i>砼方量
                </template>
                {{conInvoice.concreteStere}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-truck"></i>车号
                </template>
                {{conInvoice.carCode}}/{{conInvoice.carNo}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-truck"></i>累计车次
                </template>
                {{conInvoice.totalCar}}
            </el-descriptions-item>

        </el-descriptions>
        <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
            <template v-for="batchExpend in batchExpends">
                <el-tab-pane :label="'第' + batchExpend.batchNum + '盘'" :name="batchExpend.batchNum">
                    <el-table :data="batchExpend.labExpendList" style="width: 100%" border>
                        <el-table-column label="盘方量" width="100">
                            {{batchExpend.batchStere}}
                        </el-table-column>
                        <el-table-column label="工控材料" prop="material" width="150"></el-table-column>
                        <el-table-column label="工控仓位" prop="storage" width="150"></el-table-column>
                        <el-table-column label="本盘设定用量(KG)" prop="controlSetQuantity" width="150"></el-table-column>
                        <el-table-column label="本盘实际用量(KG)" prop="controlRealQuantity" width="150"></el-table-column>
                        <el-table-column label="下料时间" prop="useTime" width="180"></el-table-column>
                        <el-table-column label="工控编号" prop="conExpendNo" width="180"
                                         show-overflow-tooltip></el-table-column>
                    </el-table>
                </el-tab-pane>
            </template>
        </el-tabs>
    </el-dialog>
</div>
</body>
<script type="text/javascript" th:src="@{/static/console/assets/js/jquery-3.2.1.min.js}"></script>
<script type="text/javascript" th:src="@{/static/console/js/pages/base.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/static/js/vue.min.js}"></script>
<script type="text/javascript" th:src="@{/static/js/element/index.js}"></script>
<script type="text/javascript" th:src="@{/static/console/datepicker/jquery-datePicker.js}" charset="utf-8"></script>
<script th:src="@{/static/console/js/pages/production/component/indent-select.js?version=202504031025}"></script>
<script th:src="@{/static/console/js/pages/production/component/invoice-select.js?version=202504031026}"></script>
<script th:src="@{/static/console/js/pages/production/component/invoice-detail.js?version=202501071001}"></script>
<script type="text/javascript" th:src="@{/static/console/js/pages/production/control-invoice.js?version=202504031027}"
        charset="utf-8"></script>

</html>